Skip to content

1003 implement ODE SEIR metapopulation model#1273

Open
charlie0614 wants to merge 124 commits intomainfrom
1003-implement-ode-seir-metapopulation-model
Open

1003 implement ODE SEIR metapopulation model#1273
charlie0614 wants to merge 124 commits intomainfrom
1003-implement-ode-seir-metapopulation-model

Conversation

@charlie0614
Copy link
Member

@charlie0614 charlie0614 commented May 12, 2025

Changes and Information

Please briefly list the changes (main added features, changed items, or corrected bugs) made:

  • implement a different mobility model without the graph approach and only using ODEs

Replacement for #1128

If need be, add additional information and what the reviewer should look out for in particular:

Merge Request - Guideline Checklist

Please check our git workflow. Use the draft feature if the Pull Request is not yet ready to review.

Checks by code author

  • Every addressed issue is linked (use the "Closes #ISSUE" keyword below)
  • New code adheres to coding guidelines
  • No large data files have been added (files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • Tests are added for new functionality and a local test run was successful (with and without OpenMP)
  • Appropriate documentation for new functionality has been added (Doxygen in the code and Markdown files if necessary)
  • Proper attention to licenses, especially no new third-party software with conflicting license has been added
  • (For ABM development) Checked benchmark results and ran and posted a local test above from before and after development to ensure performance is monitored.

Checks by code reviewer(s)

  • Corresponding issue(s) is/are linked and addressed
  • Code is clean of development artifacts (no deactivated or commented code lines, no debugging printouts, etc.)
  • Appropriate unit tests have been added, CI passes, code coverage and performance is acceptable (did not decrease)
  • No large data files added in the whole history of commits(files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • On merge, add 2-5 lines with the changes (main added features, changed items, or corrected bugs) to the merge-commit-message. This can be taken from the briefly-list-the-changes above (best case) or the separate commit messages (worst case).

@charlie0614 charlie0614 requested a review from HenrZu May 14, 2025 11:38
@mknaranja mknaranja changed the title 1003 implement ode seir metapopulation model 1003 implement ODE SEIR metapopulation model Nov 13, 2025
@charlie0614 charlie0614 requested a review from HenrZu December 1, 2025 18:40
Copy link
Contributor

@HenrZu HenrZu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work :) Only some comments, and then we can merge :)

@charlie0614 charlie0614 requested a review from HenrZu January 8, 2026 08:22
Copy link
Contributor

@HenrZu HenrZu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Let's get this done soon. Overall, it looks very good and is an interesting addition. However, we still need to work on the presentation and documentation :)

As the model is given as a large system of ODEs, the simulation can be performed by solving the system using a standard ODE solver. The model is build on the same setup as the simpler ODE-models, so we refer to :doc:`ode` for more details.


How to: Set up and run the ODE metapopulation model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
How to: Set up and run the ODE metapopulation model
How to: Set up and run the ODE-based metapopulation model


auto result = simulate(t0, tmax, dt, model);

result.print_table();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the insight of this output? Maaybe you can output smth more interesting, or at least label the cols.

const size_t Rjn = population.get_flat_index({Region(region_n), AgeGroup(age_j), Recovered});
const size_t Sjn = population.get_flat_index({Region(region_n), AgeGroup(age_j), Susceptible});

const double Nj_inv = 1.0 / (pop[Sjn] + pop[Ejn] + pop[Ijn] + pop[Rjn]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to the model.h in the locla seir model, we should check if the population is > Limits::zero_tolerance())

const size_t Sjn = population.get_flat_index({Region(region_n), AgeGroup(age_j), Susceptible});

const double Nj_inv = 1.0 / (pop[Sjn] + pop[Ejn] + pop[Ijn] + pop[Rjn]);
double coeffStoE = 0.5 *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might potentially be a bigger problem. The coeffStoE is independent of the region. Is it possible to choose a region specific damping factor? At the moment, we just have one global contact matrix right?
I think we can solve this using the ContactMatrixGroup and the indices are the regions then.

{

/********************
* define the model *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no readme file in this dir.
I think it is important to note there, that is just an implementation of a implicit mobility scheme and that we also have a generic mobility scheme with explicit mobility (the graph-ode) for each of the available ODE models.

Simulation
----------

The simulation runs in discrete time steps using standard numerical integration schemes. Several schemes including adaptive step size methods are available, see here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see here?

How to: Set up and run a simulation of the deterministic metapopulation model
----------------------------------------------------------------------------

To set up a simulation with the deterministic SEIR metapopulation model you need to initialize the model with the desired number of regions and age groups, e.g., 3 regions and 1 age group:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about the deterministic here.

Comment on lines +36 to +43
model.parameters.template get<mio::oseirmetapop::ContactPatterns<>>()
.get_cont_freq_mat()[0]
.get_baseline()
.setConstant(2.7);

model.parameters.set<mio::oseirmetapop::TimeExposed<>>(3.335);
model.parameters.set<mio::oseirmetapop::TimeInfected<>>(8.097612257);
model.parameters.set<mio::oseirmetapop::TransmissionProbabilityOnContact<>>(0.07333);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these parameters are now set global. It would be more interesting to allow them to be set locally.

model.parameters.set<mio::oseirmetapop::TimeInfected<>>(8.097612257);
model.parameters.set<mio::oseirmetapop::TransmissionProbabilityOnContact<>>(0.07333);

Construct an ``Eigen::MatrixXd`` of size :math:`n_{regions} \times n_{regions}` which describes the fraction of individuals commuting from one region to another. The matrix should satify the sum of each row equal to 1.0, e.g.:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres not real "commuting from one region to another" in this model

ODE-based metapopulation model
================================

Introduction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just reading the file name, i would assume that this also includes the graph-ode. And whats the difference between the determinnistic_metapop and ode_metapop files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement model in which the mobility is integrated into the ODEs

3 participants